package creational.prototype;

import java.util.ArrayList;
import java.util.List;

public class BadClone implements Cloneable{

    String name;
    List<ShadowClone> childList;
    public BadClone(String _name) {
        this.name = _name;
        childList = new ArrayList<>();
        for(int i=0;i<10;i++){
            childList.add(new ShadowClone(""+i));
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<ShadowClone> getChildList() {
        return childList;
    }

    public void setChildList(List<ShadowClone> childList) {
        this.childList = childList;
    }

    @Override
    public BadClone clone(){
        BadClone parent;
        try{
            parent = (BadClone)super.clone();
            return parent;
        }catch (Exception ex){
            ex.printStackTrace();
        }
        return null;
    }
}
